package org.sofun.subscription.model;

import java.time.LocalDate;

/**
 * 日期范围辅助类
 */
public class DateRange {
    
    /**
     * 开始日期
     */
    private LocalDate start;
    
    /**
     * 结束日期
     */
    private LocalDate end;
    
    // 构造函数
    public DateRange() {
    }
    
    public DateRange(LocalDate start, LocalDate end) {
        this.start = start;
        this.end = end;
    }
    
    // Getter和Setter方法
    public LocalDate getStart() {
        return start;
    }
    
    public void setStart(LocalDate start) {
        this.start = start;
    }
    
    public LocalDate getEnd() {
        return end;
    }
    
    public void setEnd(LocalDate end) {
        this.end = end;
    }
    
    /**
     * 检查日期是否在范围内
     */
    public boolean contains(LocalDate date) {
        return !date.isBefore(start) && !date.isAfter(end);
    }
    
    /**
     * 获取范围内的天数
     */
    public long getDays() {
        return start.until(end).getDays() + 1;
    }
    
    @Override
    public String toString() {
        return "DateRange{" +
                "start=" + start +
                ", end=" + end +
                '}';
    }
}
